<?php

/**
 * GameLearn filter form base class.
 *
 * @package    aiontoolskit
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseGameLearnFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'        => new sfWidgetFormFilterInput(),
      'faction_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('GameFaction'), 'add_empty' => true)),
      'class_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('GameClass'), 'add_empty' => true)),
      'pc_level'    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'skill'       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'skill_level' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'auto_learn'  => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
    ));

    $this->setValidators(array(
      'name'        => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'faction_id'  => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('GameFaction'), 'column' => 'id')),
      'class_id'    => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('GameClass'), 'column' => 'id')),
      'pc_level'    => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'skill'       => new sfValidatorPass(array('required' => false)),
      'skill_level' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'auto_learn'  => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
    ));

    $this->widgetSchema->setNameFormat('game_learn_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'GameLearn';
  }

  public function getFields()
  {
    return array(
      'id'          => 'Number',
      'name'        => 'Number',
      'faction_id'  => 'ForeignKey',
      'class_id'    => 'ForeignKey',
      'pc_level'    => 'Number',
      'skill'       => 'Text',
      'skill_level' => 'Number',
      'auto_learn'  => 'Boolean',
    );
  }
}
